<?php
    $tel=$_REQUEST['tel'];
	$p=0;
	$con=mysqli_connect('localhost', 'root', '', 'friday');
	if($con){
		mysqli_set_charset($con,'utf8');
		$sql3="select money from accountstate where telphone='{$tel}' ";
	   $result3=mysqli_query($con,$sql3);
	   $arr3=mysqli_fetch_all($result3,MYSQLI_ASSOC);
	   	   foreach ($arr3 as $key => $value) {
	   	foreach ($value as $k => $val) {
	   		$p=$p+$val;
	   	};
	   };
	   $sql4="update accountstate set totlemoney='{$p}' where telphone='{$tel}' limit 1";
	   $result4=mysqli_query($con, $sql4);
	   		
		$sql2="select totlemoney from accountstate  where telphone='{$tel}' limit 1";
		$result2=mysqli_query($con,$sql2);
		$arr=mysqli_fetch_all($result2,MYSQLI_ASSOC);
		$str=json_encode($arr);
		echo $str;

	
	}else {
		echo "链接未遂".mysqli_connect_error();
	}
	
	mysqli_close($con);
	
	
	
	?>